import requests
import re

headers = {
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Content-Type': 'application/json',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36'
}

def RequestBody(text):
    arr = []
    # 正则表达式：匹配英文单词，不区分大小写
    pattern = r'\b[a-zA-Z]+\b'
    # 使用 re.findall 查找所有匹配的单词
    matches = re.findall(pattern, text, re.IGNORECASE)
    if len(matches) == 0:
        json_data = {
            'query': text,
            'from': 'zh',
            'to': 'en',
            'reference': '',
            'corpusIds': [],
            'needPhonetic': False,
            'domain': 'common',
            'milliTimestamp': 1737600881992,
        }
        arr.append(json_data)
        return arr
    else:
        for i in matches:
            json_data = {
                'query': i,
                'from': 'en',
                'to': 'zh',
                'reference': '',
                'corpusIds': [],
                'needPhonetic': False,
                'domain': 'common',
                'milliTimestamp': 1737600881992,
            }
            arr.append(json_data)
        return arr

def ask(arrJsonData):
    arrText = []
    regularStr = '"dst":"(.*?)"'
    url = "https://fanyi.baidu.com/ait/text/translate"
    for i in arrJsonData:
        response = requests.post(url,headers = headers,json=i)
        result = re.findall(regularStr,response.text)
        arrText.append(''.join(result))
    return arrText


def main():
    text = input()
    arrJsonData = RequestBody(text)

    result = ask(arrJsonData)

    print("".join(result))

if __name__ == '__main__':
    main()
